//
//  recordViewController.m
//  0908-cckv
//
//  Created by zhoubaitong on 2017/9/18.
//  Copyright © 2017年 cckv. All rights reserved.
//

#import "recordViewController.h"
#import "dataModel.h"
@interface recordViewController ()

@property (nonatomic, strong) NSArray *dataArray; ///< <#name#>

@end

@implementation recordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    self.title = @"我的成绩";
    UILabel *lab = [[UILabel alloc]init];
    lab.text = NSLocalizedString(@"我的成绩", nil);
    lab.frame = CGRectMake(0, 0, 100, 40);
    lab.textColor = [UIColor whiteColor];
    lab.font = [UIFont systemFontOfSize:20];
    self.navigationItem.titleView = lab;
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[[UIImage imageNamed:@"返回return"] imageByTintColor:[UIColor whiteColor]] forState:UIControlStateNormal];
    btn.frame = CGRectMake(0, 0, 20, 20);
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btn];
    [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuseIdentifier"];
    
    self.dataArray = [dataModel findAll];
    [self.tableView reloadData];
}
- (void)back
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.dataArray.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"reuseIdentifier"];
    
    dataModel *model = self.dataArray[indexPath.row];
    
    cell.textLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"score:", nil),model.score];
    cell.detailTextLabel.text = model.timeStr;
    
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}

@end
